<?php
##############################################
#
#   活动详情页
# @ Time : 2017-3-1 - 下午11:55:14
# @ Author : JiangYongWei <1085562810@qq.com>
# @ Encoding : UTF-8 language : PHP
#
##############################################

namespace Home\Controller;
use Home\Model\ActivityCategoryModel;
use Home\Model\ActivityModel;

class ActivityCategoryController extends BaseController{
	private $_activity_category;
	
	public function _initialize(){
	    parent::_initialize();
	    $this->_activity_category = new ActivityCategoryModel();
	}
	
	/**
	 * 更多分类
	 */
	public function index(){
	    $data = $this->_activity_category->getAllCategory();
	    $this->assign('category', $data);
	    $this->display('category');
	}
	
	/**
	 * 活动列表筛选
	 */
	public function activityList() {
	    $categoty_data = $this->_activity_category->getAllCategory();
	    
	    $city = urldecode(str_replace('|','%',I('city'))) ? urldecode(str_replace('|','%',I('city'))) : '广州市';
	    $this->assign('city', $city);
	    $city_select = urlencode($city);
	    $city_select = str_replace('%', '|', $city_select);
	    $this->assign('city_select', $city_select);
	    $city = mb_substr($city,0,strlen($city)-3);
	    $activity_model = new ActivityModel();
	    $activity_data = $activity_model->activityList($city, I('activity_name'), I('category'), I('new_or_hot'), I('price'));
	    //showData($activity_data[0]);
	    $this->assign('category', $categoty_data);
	    $this->assign('activity', $activity_data[0]);
	    if(count($activity_data[0]) > 0){
	        $this->assign('activity_show', 1);
	    }
	    $this->assign('activity_name', $activity_name);
	    $this->assign('category_id', I('category'));
	    $this->assign('new_or_hot', I('new_or_hot'));
	    $this->assign("price", I('price'));
	    if ($_GET['is_ajax']) {
	        $this->display('ajax_activity_list');
	        exit;
	    }
	    $this->display('activity_list');
	}
	
	
}